<?php
/**
 * Created by JetBrains PhpStorm.
 * File: CommonAction.class.php
 * User: Xnfy520@gmail.com
 * Date: 12-3-15
 * Time: 上午3:29
 */

	class CommonAction extends Action{

		function _initialize(){
			header("Content-Type:text/html;Charset=utf-8;");
			$section = M('Section');
			$sections = $section->field('id, name')->select();
			$this->assign('sections', $sections);

			$category = M('Category');
			$categorys = $category->field('id, name, sectionid')->select();
			$this->assign('categorys', $categorys);

			$menu = M('Menu');
			$menus = $menu->field('id, name')->select();
			$this->assign('menus', $menus);

			$node = M('Node');
			$apps = $node->field('id, remark')->where('pid=0')->select();
			$this->assign('apps', $apps);

			// 用户权限检查
			if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
				import('ORG.Util.RBAC');
				if (!RBAC::AccessDecision()) {
					//检查认证识别号
					if (!$_SESSION [C('USER_AUTH_KEY')]) {
						//跳转到认证网关
						redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
					}
					// 没有权限 抛出错误
					if (C('RBAC_ERROR_PAGE')) {
						// 定义权限错误页面
						redirect(C('RBAC_ERROR_PAGE'));
					} else {
						if (C('GUEST_AUTH_ON')) {
							$this->assign('jumpUrl', PHP_FILE . C('USER_AUTH_GATEWAY'));
						}
						// 提示错误信息
						$this->error(L('_VALID_ACCESS_'));
					}
				}

			}


		}

	}